package com.jsu.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.model.user.pojo.Speaker;

import java.util.Date;
import java.util.List;

@Mapper
public interface SpeakerMapper extends BaseMapper<Speaker> {

    @Select("SELECT * FROM speaker")

    List<Speaker> selectSpeaker();


    @Select("SELECT s.*\n" +
            "FROM speaker s\n" +
            "         JOIN flow_speaker fs ON s.speaker_id = fs.speaker_id\n" +
            "         JOIN activity_flow af ON fs.flow_id = af.activity_flow_id\n" +
            "         JOIN activity a ON af.activity_id = a.pk_id\n" +
            "WHERE a.activity_date = #{date} AND fs.type = '1';\n")
    List<Speaker> selectSpeakerByDate(@Param("date") Date date);

    @Select("SELECT s.*\n" +
            "FROM speaker s\n" +
            "JOIN flow_speaker fs ON s.speaker_id = fs.speaker_id\n" +
            "JOIN activity_flow af ON fs.flow_id = af.activity_flow_id\n" +
            "JOIN activity a ON af.activity_id = a.pk_id\n" +
            "WHERE a.type = #{type} AND fs.type = '1';\n")
    List<Speaker> selectSpeakerByType(@Param("type") Integer type);


    @Select("SELECT s.*\n" +
            "FROM speaker s\n" +
            "JOIN flow_speaker fs ON s.speaker_id = fs.speaker_id\n" +
            "JOIN activity_flow af ON fs.flow_id = af.activity_flow_id\n" +
            "JOIN activity a ON af.activity_id = a.pk_id\n" +
            "WHERE a.type = #{type} AND a.activity_date = #{date} AND fs.type = '1';\n")
    List<Speaker> selectSpeakerByDateAndType(@Param("date") Date date,@Param("type") Integer type);


}
